package cn.edu.njust.util;


import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.Connection;
import java.util.Properties;

/**
 * Druid数据库连接池测试
 */
public class DruidDemo {
//,l
    public static void main(String[] args) throws Exception {
        //加载配置文件
        Properties prop = new Properties();
        InputStream is = DruidDemo.class.getResourceAsStream("/druid.properties");
        prop.load(is);
        //获取连接池对象
        DataSource dataSource = DruidDataSourceFactory.createDataSource(prop);
        //获取数据库连接 Connection
        Connection connection = dataSource.getConnection();
        System.out.println(connection);
        //System.out.println(System.getProperty("user.dir"));
    }
}
